import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/Login',
    name: 'login',
    component: () => import('@/views/login.vue'),
  },
  {
    path: '/home',
    name: 'HomeView',
    component: () => import('@/views/HomeView.vue'),
    meta: { title: '首页' },
    children: [
      {
        path: '/memberManagement',
        name: 'MemberManagement',
        component: () => import('@/views/children/MemberManagement'),
        redirect: '/memberRecord',
        meta: { title: '会员管理' },
        children: [{
            path: '/memberAddUp',
            component: () => import('@/views/children/components/allUser'),
            name: 'MemberAddUp',
            meta: { title: '会员统计' },
          }, {
            path: '/memberRecord',
            component: () => import('@/views/children/components/MemberRecordView'),
            name: 'MemberRecordView',
            meta: { title: '会员档案' },
            // 懒加载
          }, {
            path: '/physicalExaminationUp',
            component: () => import('@/views/children/components/PhysicalExaminationUpView'),
            name: 'PhysicalExaminationUpView',
            meta: { title: '体检上传' },
          }]
      },
      {
        path: '/appointmenManagement',
        name: 'AppointmenManagement',
        component: () => import('@/views/children/AppointmenManagement'),
        redirect: '/appointmentList',
        meta: { title: '预约管理' },
        children: [{
          path: '/appointmentList',
          name: 'AppointmentList',
          meta: { title: '预约列表' },
          component: () => import('@/views/children/components/AppointmentListView'),
        }]
      }
    ]
  },
  // 路由重定向
  {
    path: "*",
    // 名字在“命名路由”中使用。但是不介绍
    name: "any",
    redirect: "/login"
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
